{%- if grains['role'] == 'so-eval' -%}
{%- set ES = salt['pillar.get']('manager:mainip', '') -%}
{%- else %}
{%- set ES = salt['pillar.get']('elasticsearch:mainip', '') -%}
{%- endif %}
{%- set ES_USER = salt['pillar.get']('elasticsearch:auth:users:so_elastic_user:user', '') %}
{%- set ES_PASS = salt['pillar.get']('elasticsearch:auth:users:so_elastic_user:pass', '') %}
filter {
  if [event][module] =~ "endgame" {
    mutate {
      remove_field => ["client_headers", "client_host"]
    }
  }
}
output {
  if [event][module] =~ "endgame" {
    elasticsearch {
      id => "endgame_es_output"
      hosts => "{{ ES }}"
    {% if salt['pillar.get']('elasticsearch:auth:enabled') is sameas true %}
      user => "{{ ES_USER }}"
      password => "{{ ES_PASS }}"
    {% endif %}
      index => "endgame-%{+YYYY.MM.dd}"
      ssl => true
      ssl_certificate_verification => false
    }
  }
}
